/*
 * Unit.java
 */

package units;

import java.awt.Point;
import java.util.ArrayList;
import java.util.List;

import enums.UnitType;
import terrain.WorldObject;

/**
 * 
 * 
 * @author Travis Drake
 * 
 * @version Oct 3, 2012
 */
public class Unit
{
    private UnitType my_unit_type;
    
    private int my_atk_dmg;
    
    private int my_hp;
    
    private int my_strength;
    
    private Point my_coords;
    
    private List<WorldObject> my_carrying;
    
    
    public Unit(final UnitType the_unit_type)
    {
        my_unit_type = the_unit_type;
        my_carrying = new ArrayList<WorldObject>();
        my_coords = null;
        my_hp = 0;
        my_atk_dmg = 0;
        my_strength = 0;
    }
    
    
    
    public Unit(final UnitType the_unit_type, final int the_hp, final int the_atk_dmg, final int the_strength)
    {
        this(the_unit_type);
        my_hp = the_hp;
        my_atk_dmg = the_atk_dmg;
        my_strength = the_strength;
    }
    


    public Unit(final UnitType the_unit_type, final Point the_coords, final int the_hp, final int the_atk_dmg,
                final int the_strength)
    {
        this(the_unit_type, the_hp, the_atk_dmg, the_strength);
        
        
        my_coords = (Point) the_coords.clone();     
        //We dont want to ever risk modifying the original point that we were given, in case it changes the
        //coords of the unit that said point came from. Therefore we clone the point.
        //Clone() is a method for class "Object" that all of our classes inherit, provided said class
        //implements the "Cloneable" interface. Problem is, because it is a method for type "Object", 
        //calling .clone() on an object of class "Foo" returns an Object of type "Object" with copies of
        //"Foo"'s fields and their values. Therefore we must type-cast this object to type "Foo" before it
        //may be used as such.
    }
    
    
    /**
     * Gets the units current coordinates in point form.
     * 
     * @return the units current coordinates.
     */
    public Point getCoords()
    {
        return my_coords;
    }
    
    
    /**
     * Sets new coordinates for the unit to those of a provided point.
     * 
     * @param the_point the point who's values to use for the units new coordinates.
     */
    public void setCoords(Point the_point)
    {
        my_coords = (Point) the_point.clone();
    }
    
    
    /**
     * Sets new coordinates for the unit using provided X and Y values.
     * 
     * @param the_x the new x coordinate.
     * @param the_y the new y coordinate.
     */
    public void setCoords(final int the_x, final int the_y)
    {
        my_coords = new Point(the_x, the_y);
    }
    
    
    
    /**
     * Gets the units current attack damage.
     * 
     * @return the units current attack damage.
     */
    public int getAtkDmg()
    {
        return my_atk_dmg;
    }



    /**
     * Sets the units current attack damage.
     * 
     * @param the_atk_dmg the new attack damage for the unit.
     */
    public void setAtkDmg(final int the_atk_dmg)
    {
        my_atk_dmg = the_atk_dmg;
    }



    /**
     * Gets the units current HP value.
     * 
     * @return the units current HP.
     */
    public int getHp()
    {
        return my_hp;
    }



    /**
     * Sets the units HP.
     * 
     * @param the_hp the new HP value.
     */
    public void setHp(final int the_hp)
    {
        my_hp = the_hp;
    }



    /**
     * Gets the units strength. 
     * 
     * @return the units strength
     */
    public int getStrength()
    {
        return my_strength;
    }



    /**
     * Sets the units strength.
     * 
     * @param the_strength the my_strength to set
     */
    public void setStrength(final int the_strength)
    {
        my_strength = the_strength;
    }


}

